import { UserTypeEnum } from "@/enums/appointmentStatusEnums";
import { USER_TYPE_KEY } from "@/enums/cacheEnum";
const useTabBarStore = defineStore("tabBar", () => {
	// 设置tabbar
	function setTab() {
		const userType = cache.get(USER_TYPE_KEY);
		switch (userType) {
			// 社会用户
			case UserTypeEnum.SOCIALUSERS:
				uni.setTabBarItem({
					index: 0,
					visible: true,
				});
				uni.setTabBarItem({
					index: 1,
					visible: false,
				});
				uni.setTabBarItem({
					index: 2,
					visible: false,
				});
				uni.setTabBarItem({
					index: 3,
					visible: false,
				});
				uni.setTabBarItem({
					index: 4,
					visible: true,
				});
				uni.setTabBarItem({
					index: 5,
					visible: false,
				});
				uni.setTabBarItem({
					index: 6,
					visible: false,
				});

				break;
			// 客户经理
			case UserTypeEnum.ACCOUNTMANAGER:
				uni.setTabBarItem({
					index: 0,
					visible: false,
				});
				uni.setTabBarItem({
					index: 1,
					visible: true,
				});
				uni.setTabBarItem({
					index: 2,
					visible: false,
				});
				uni.setTabBarItem({
					index: 3,
					visible: false,
				});
				uni.setTabBarItem({
					index: 4,
					visible: false,
				});
				uni.setTabBarItem({
					index: 5,
					visible: true,
				});
				uni.setTabBarItem({
					index: 6,
					visible: false,
				});

				break;
			// 科室管理员
			case UserTypeEnum.SECTIONADMINISTATOR:
				uni.setTabBarItem({
					index: 0,
					visible: false,
				});
				uni.setTabBarItem({
					index: 1,
					visible: false,
				});
				uni.setTabBarItem({
					index: 2,
					visible: true,
				});
				uni.setTabBarItem({
					index: 3,
					visible: false,
				});
				uni.setTabBarItem({
					index: 4,
					visible: false,
				});
				uni.setTabBarItem({
					index: 5,
					visible: false,
				});

				uni.setTabBarItem({
					index: 6,
					visible: true,
				});
				break;
			// 部门管理员
			case UserTypeEnum.DEPARTMENTADMINISTATOR:
				uni.setTabBarItem({
					index: 0,
					visible: false,
				});
				uni.setTabBarItem({
					index: 1,
					visible: false,
				});
				uni.setTabBarItem({
					index: 2,
					visible: true,
				});
				uni.setTabBarItem({
					index: 3,
					visible: false,
				});
				uni.setTabBarItem({
					index: 4,
					visible: false,
				});
				uni.setTabBarItem({
					index: 5,
					visible: false,
				});

				uni.setTabBarItem({
					index: 6,
					visible: true,
				});
				break;
			// 讲解员
			case UserTypeEnum.GUIDE:
				uni.setTabBarItem({
					index: 0,
					visible: false,
				});
				uni.setTabBarItem({
					index: 1,
					visible: false,
				});
				uni.setTabBarItem({
					index: 2,
					visible: false,
				});
				uni.setTabBarItem({
					index: 3,
					visible: true,
				});
				uni.setTabBarItem({
					index: 4,
					visible: false,
				});
				uni.setTabBarItem({
					index: 5,
					visible: true,
				});

				uni.setTabBarItem({
					index: 6,
					visible: false,
				});
				break;
			// 产品室
			case UserTypeEnum.PRODUCTROOMMANAGER:
				uni.setTabBarItem({
					index: 0,
					visible: false,
				});
				uni.setTabBarItem({
					index: 1,
					visible: false,
				});
				uni.setTabBarItem({
					index: 2,
					visible: true,
				});
				uni.setTabBarItem({
					index: 3,
					visible: false,
				});
				uni.setTabBarItem({
					index: 4,
					visible: false,
				});
				uni.setTabBarItem({
					index: 5,
					visible: false,
				});

				uni.setTabBarItem({
					index: 6,
					visible: true,
				});
				break;
			// 领导
			case UserTypeEnum.ACCOMPANYTHEMANAGER:
				uni.setTabBarItem({
					index: 0,
					visible: false,
				});
				uni.setTabBarItem({
					index: 1,
					visible: false,
				});
				uni.setTabBarItem({
					index: 2,
					visible: false,
				});
				uni.setTabBarItem({
					index: 3,
					visible: true,
				});
				uni.setTabBarItem({
					index: 4,
					visible: false,
				});
				uni.setTabBarItem({
					index: 5,
					visible: false,
				});

				uni.setTabBarItem({
					index: 6,
					visible: true,
				});
				break;

			default:
				break;
		}
	}
	// 区分用户跳转首页
	function toMine() {
		const userType = cache.get(USER_TYPE_KEY);
		switch (userType) {
			// 社会用户
			case UserTypeEnum.SOCIALUSERS:
				uni.switchTab({
					url: "/pages/mine/socialUsers/index",
				});
				break;
			// 客户经理
			case UserTypeEnum.ACCOUNTMANAGER:
				uni.switchTab({
					url: "/pages/mine/managers/index",
				});
				break;
			// 科室管理员
			case UserTypeEnum.SECTIONADMINISTATOR:
				uni.switchTab({
					url: "/pages/mine/departmentManagers/index",
				});
				break;
			// 部门管理员
			case UserTypeEnum.DEPARTMENTADMINISTATOR:
				uni.switchTab({
					url: "/pages/mine/managers/index",
				});
				break;
			// 讲解员
			case UserTypeEnum.GUIDE:
				uni.switchTab({
					url: "/pages/mine/managers/index",
				});
				break;

			default:
				break;
		}
	}
	return {
		setTab,
		toMine,
	};
});
export default useTabBarStore;
